
ASSUME CS:CODE, DS:DATA, SS:STACK
DATA segment
         dw 100, 98, 79, 83, 56, 0, 0, 0
         dw 'aa', 'bb', 'cc', 'dd', 'ee', 0, 0, 0
    
DATA ends
STACK segment
          dw 16 dup(0)
STACK ends
CODE segment
    
    start:      mov  ax, DATA
                mov  ds, ax

                mov  ax, STACK
                mov  ss, ax
                mov  sp, 32

                mov  bh,10
                mov  cx, 5
                mov  si, 0
    s:          call outputName
                mov ah, 2
                mov dl, ' '
                int 21h
                call outputScore
                mov  dl, 10
                int  21h
                add  si, 2
                loop s

                mov  ax, 4c00h
                int  21h


outputScore proc                       ;输出函数
                mov  bl,0              ; 统计当前数字有几个十进制位
                mov  ax,ds:[si]
    inStack:    div  bh
                push ax                ;入栈
                add  bl,1              ;计数器加一
                mov  ah,0
                cmp  ax,0              ;当被除数为0时结束循环
                jne  inStack
    outStack:   pop  dx                ;出栈
                sub  bl,1              ;计数器减一
                mov  dl,dh
                add  dl,48
                mov  ah,2
                int  21h
                cmp  bl,0              ;当计数器清零时结束循环
                jne  outStack
                ret
outputScore endp
outputName proc
                mov  ah, 2
                mov  dl, ds:[16+si]
                int  21h
                mov  dl, ds:[17+si]
                int  21h
                ret
outputName endp
              

CODE ends
end start